home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1995 August / PC Plus Super CD (Issue 106) (PCP106) (August 1995).iso / vbtools / vvbdem / disk1 / versvb.ms_ / versvb.ms
Encoding:
Text File  |  1994-12-19  |  12.0 KB  |  392 lines

  1. '**************************************************************************
  2. '*                       MSSetup Toolkit Versions/VB
  3. '**************************************************************************
  4.  
  5. '**************************************************************************
  6. '*
  7. '*    Special notes:
  8. '*
  9. '*        1) The 3-D control stuff still does not work.
  10. '*
  11. '**************************************************************************
  12.  
  13. ''$DEFINE DEBUG  ''Define for script development/debugging
  14.  
  15. '$INCLUDE 'setupapi.inc'
  16. '$INCLUDE 'msdetect.inc'
  17.  
  18. ''Windows API include stuff
  19. CONST WS_VISIBLE=&H10000000
  20. CONST WS_BORDER =&H00800000
  21. CONST WS_CLIPCHILDREN =&H02000000
  22. CONST GWL_STYLE =-16
  23. CONST SW_SHOWMAXIMIZED=3
  24.  
  25. '' Declare Windows API functions
  26. DECLARE FUNCTION ShowWindow  LIB "user.exe" (hWnd%, iShow%) AS INTEGER
  27. DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG
  28.  
  29. '' Declare 3-D Control Library
  30. ''DECLARE FUNCTION Ctl3dRegister LIB "mscuistf.dll" (hInstance%) AS LONG
  31. ''DECLARE FUNCTION Ctl3dAutoSubclass LIB "mscuistf.dll" (hInstance%) AS LONG
  32. ''DECLARE FUNCTION Ctl3dUnRegister LIB "mscuistf.dll" (hInstance%) AS LONG
  33.  
  34. ''Dialog ID's
  35. CONST WELCOME       = 100
  36. CONST ASKQUIT       = 200
  37. CONST DESTPATH      = 300
  38. CONST EXITFAILURE   = 400
  39. CONST EXITQUIT      = 600
  40. CONST EXITSUCCESS   = 700
  41. CONST APPHELP       = 110
  42. CONST PATHHELP        = 310
  43. CONST BADPATH       = 6400
  44.  
  45. CONST CDPREVINSTALL    = 7100
  46. CONST CDCONFIRMINFO    = 7300
  47. CONST CDGETNAMEORGSERIALNO    = 7500
  48. CONST CDNAMEQ        = 7700
  49. CONST CDORGREQ        = 7800
  50. CONST CDSERIALREQ    = 7900
  51.  
  52. CONST BILLBOARDEASYTOUSE    = 9000
  53. CONST BILLBOARDPOWERFULL    = 9001
  54. CONST BILLBOARDCONFIGURABLE    = 9002
  55. CONST BILLBOARDREGISTER        = 9003
  56.  
  57. ''Bitmap ID
  58. CONST LOGO = 1
  59.  
  60. GLOBAL DEST$        ''Default destination directory.
  61.  
  62. DECLARE SUB Install (sCustName$, sOrgName$, sSerialNo$)
  63. DECLARE FUNCTION MakePath (sDir$, sFile$) AS STRING
  64. DECLARE SUB UninstallPrevious (sDir$)
  65. DECLARE SUB RemovePrevInstalledFile (sDir$, sFile$)
  66.  
  67. INIT:
  68.     '' Register 3d library
  69. ''    hInstance% = HinstFrame()
  70. ''    i1&=Ctl3dRegister(hInstance%)
  71. ''    i1&=Ctl3dAutoSubclass(hInstance%)
  72.  
  73.     ''Maximise frame window
  74.     i1&=SetWindowLong(HwndFrame(), GWL_STYLE, WS_VISIBLE + WS_BORDER + WS_CLIPCHILDREN)
  75.     j1%=ShowWindow(HwndFrame(), SW_SHOWMAXIMIZED)
  76.  
  77.     i% = SetSizeCheckMode(scmOff)        '' could use scmOff; def = scmOnFatal
  78.  
  79.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  80.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  81.  
  82.     SetBitmap CUIDLL$, LOGO
  83.     SetTitle "VERSIONS/VB 1.1c Setup"
  84.  
  85.     sInf$ = GetSymbolValue("STF_SRCINFPATH")
  86.     IF sInf$ = "" THEN
  87.         sInf$ = GetSymbolValue("STF_CWDDIR") + "VERSVB.INF"
  88.     END IF
  89.     ReadInfFile sInf$
  90.  
  91.     ''Setup billboard
  92.     AddToBillboardList CUIDLL$, BILLBOARDEASYTOUSE, "FBillBoardEasyToUseDlgProc", 1
  93.     AddToBillboardList CUIDLL$, BILLBOARDPOWERFULL, "FBillBoardPowerfullDlgProc", 1
  94.     AddToBillboardList CUIDLL$, BILLBOARDCONFIGURABLE, "FBillBoardConfigurableDlgProc", 1
  95.     AddToBillboardList CUIDLL$, BILLBOARDREGISTER, "FBillBoardRegisterDlgProc", 1
  96.  
  97.     DEST$ = "C:\VERSVB"
  98.     AddSectionFilesToCopyList "system", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
  99.  
  100. '$IFDEF DEBUG
  101.     i% = SetSizeCheckMode(scmOnFatal)    '' could use scmOff; def = scmOnFatal
  102.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  103.     IF IsDriveValid(WinDrive$) = 0 THEN
  104.         i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  105.         GOTO QUIT
  106.     END IF
  107. '$ENDIF ''DEBUG
  108.  
  109.  
  110. WELCOME:
  111.     s$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  112.     IF s$ = "CONTINUE" THEN
  113.         UIPop 1
  114.     ELSE
  115.         GOSUB ASKQUIT
  116.         GOTO WELCOME
  117.     END IF
  118.  
  119.     sCustName$ = ""
  120.     sOrgName$ = ""
  121.     sSerialNo$ = ""
  122. GETUSERNAME:
  123.     if DoesFileExist(GetSymbolValue ("STF_SRCDIR")+"versvb.dat", femExists) then
  124.  
  125.         '' Check for a previously used disk and put up the legal warning dialog box.
  126.         open GetSymbolValue ("STF_SRCDIR")+"versvb.dat" for input as #1
  127.         line input #1, NameIn$
  128.         line input #1, OrgIn$
  129.         line input #1, SerialIn$
  130.         close #1
  131.  
  132.         '' display previous name and organization information
  133.         AddListItem "ConfirmTextIn", NameIn$
  134.         AddListItem "ConfirmTextIn", OrgIn$
  135.         AddListItem "ConfirmTextIn", SerialIn$
  136.  
  137.         result$=UIStartDlg ("mscuistf.dll", CDPREVINSTALL, "FConfirmDlgProc", APPHELP, HELPPROC$)
  138.         if result$="CONTINUE" then
  139.             UIPop 1
  140.         else
  141.             goto ASKQUIT
  142.         end if
  143.           sCustName$ = NameIn$
  144.         sOrgName$ = OrgIn$
  145.         sSerialNo$ = SerialIn$
  146.     else
  147. GetOrgNameSerialNo:
  148.         '' Obtain name and organization information
  149.         SetSymbolValue "sCustName", sCustName$
  150.         SetSymbolValue "sOrgName", sOrgName$
  151.         SetSymbolValue "sSerialNo", sSerialNo$
  152.  
  153.         result$=UIStartDlg ("mscuistf.dll", CDGETNAMEORGSERIALNO, "FNameOrgSerialNoDlgProc", APPHELP, HELPPROC$)
  154.         if result$="CONTINUE" then
  155.             UIPop 1
  156.         else
  157.             goto ASKQUIT
  158.         end if
  159.  
  160.         sCustName$=GetSymbolValue ("NameOut")
  161.         sOrgName$=GetSymbolValue ("OrgOut")
  162.         sSerialNo$=GetSymbolValue ("SerialOut")
  163.  
  164.         if sCustName$="" then
  165.             result$ = UIStartDlg ("mscuistf.dll", CDNAMEREQ, "FNameOrgSerialNoDlgProc", APPHELP, HELPPROC$)
  166.             UIPop 1
  167.             goto GetOrgNameSerialNo
  168.         endif
  169.  
  170.         if sOrgName$="" then
  171.             result$ = UIStartDlg ("mscuistf.dll", CDORGREQ, "FNameOrgSerialNoDlgProc", APPHELP, HELPPROC$)
  172.             UIPop 1
  173.             goto GetOrgNameSerialNo
  174.         endif
  175.  
  176.         if sSerialNo$="" then
  177.             result$ = UIStartDlg ("mscuistf.dll", CDSERIALREQ, "FNameOrgSerialNoDlgProc", APPHELP, HELPPROC$)
  178.             UIPop 1
  179.             goto GetOrgNameSerialNo
  180.         endif
  181.  
  182.         '' Display confirmation dialog
  183.         SetSymbolValue "ConfirmTextIn", ""
  184.         AddListItem "ConfirmTextIn", sCustName$
  185.         AddListItem "ConfirmTextIn", sOrgName$
  186.         AddListItem "ConfirmTextIn", sSerialNo$
  187.  
  188.         result$=UIStartDlg ("mscuistf.dll", CDCONFIRMINFO, "FConfirmDlgProc", APPHELP, HELPPROC$)
  189.         UIPop 1
  190.         if result$="BACK" then 
  191.             goto GetOrgNameSerialNo
  192.         end if
  193.  
  194.         '' Save organization information to a file on disk 1.
  195.         open GetSymbolValue ("STF_SRCDIR")+"versvb.dat" for output as #1
  196.         print #1, sCustName$
  197.         print #1, sOrgName$
  198.         print #1, sSerialNo$
  199.         close #1
  200.     end if
  201.  
  202. GETPATH:
  203.     SetSymbolValue "EditTextIn", DEST$
  204.     SetSymbolValue "EditFocus", "END"
  205. GETPATHL1:
  206.     result$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", PATHHELP, HELPPROC$)
  207.     DEST$ = GetSymbolValue("EditTextOut")
  208.  
  209.     IF result$ = "CONTINUE" THEN
  210.         IF IsDirWritable(DEST$) = 0 THEN
  211.             GOSUB BADPATH
  212.             GOTO GETPATHL1
  213.         END IF
  214.         UIPop 1
  215.     ELSEIF result$ = "REACTIVATE" THEN
  216.         GOTO GETPATHL1
  217.     ELSEIF result$ = "BACK" THEN
  218.         UIPop 1
  219.         GOTO GetOrgNameSerialNo
  220.     ELSE
  221.         GOSUB ASKQUIT
  222.         GOTO GETPATH
  223.     END IF
  224.  
  225.     Install sCustName$, sOrgName$, sSerialNo$
  226.     UninstallPrevious DEST$
  227.  
  228.     if RestartListEmpty() = 0 then
  229.         i% = ExitExecRestart()
  230.     end if
  231.  
  232.  
  233. QUIT:
  234.     ON ERROR GOTO ERRQUIT
  235.  
  236.     IF ERR = 0 THEN
  237.         dlg% = EXITSUCCESS
  238.     ELSEIF ERR = STFQUIT THEN
  239.         dlg% = EXITQUIT
  240.     ELSE
  241.         dlg% = EXITFAILURE
  242.     END IF
  243. QUITL1:
  244.     result$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  245.     IF result$ = "REACTIVATE" THEN
  246.         GOTO QUITL1
  247.     END IF
  248.     UIPop 1
  249. ''    i1&=Ctl3dUnregister(hInstance%)
  250.     END
  251.  
  252. ERRQUIT:
  253.     i% = DoMsgBox("Setup sources are corrupted, call StarBase Corporation at (714) 253-6700", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  254. ''    i1&=Ctl3dUnregister(hInstance%)
  255.     END
  256.  
  257.  
  258.  
  259. BADPATH:
  260.     result$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  261.     IF result$ = "REACTIVATE" THEN
  262.         GOTO BADPATH
  263.     END IF
  264.     UIPop 1
  265.     RETURN
  266.  
  267.  
  268.  
  269. ASKQUIT:
  270.     result$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  271.     IF result$ = "EXIT" THEN
  272.         UIPopAll
  273.         ERROR STFQUIT
  274.     ELSEIF result$ = "REACTIVATE" THEN
  275.         GOTO ASKQUIT
  276.     ELSE
  277.         UIPop 1
  278.     END IF
  279.     RETURN
  280.  
  281.  
  282.  
  283. '*************************************************************************
  284. '**
  285. '** Purpose:
  286. '**     Builds the copy list and performs all installation operations.
  287. '** Arguments:
  288. '**     sCustName$ - Custormer Name.
  289. '**     sOrgName$ - Organization Name.
  290. '**     sSerialNo$ - Product Serial Number.
  291. '** Returns:
  292. '**     none.
  293. '**
  294. '*************************************************************************
  295. SUB Install (sCustName$, sOrgName$, sSerialNo$) STATIC
  296.  
  297.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  298.     CreateDir DEST$, cmoNone
  299.  
  300.     OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
  301.     WriteToLogFile ""
  302.     WriteToLogFile "  User chose as destination directory: '" + DEST$ + "'"
  303.     WriteToLogFile ""
  304.     WriteToLogFile "May have had to create the directory: " + DEST$
  305.     WriteToLogFile ""
  306.  
  307.     AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  308.     CopyFilesInCopyList
  309.  
  310.     stampstring$=CHR$(LEN(sCustName$))+sCustName$+CHR$(LEN(sOrgName$))+sOrgName$+CHR$(LEN(sSerialNo$))+sSerialNo$
  311.     StampResource "system", "VersHookDll", GetWindowsSysDir(), 6, &H451, stampstring$, LEN(stampstring$)
  312.     StampResource "Files", "VisDiffExe", DEST$, 6, &H451, stampstring$, LEN(stampstring$)
  313.  
  314.     CreateProgmanGroup "Versions/VB 1.1c", "", cmoNone
  315.     ShowProgmanGroup  "Versions/VB 1.1c", 1, cmoNone
  316.     CreateProgmanItem "Versions/VB 1.1c", "Versions/VB 1.1c", MakePath(DEST$,"VERSVB.EXE"), "", cmoOverwrite
  317.     CreateProgmanItem "Versions/VB 1.1c", "Versions/VB 1.1c Help", "WINHELP.EXE "+MakePath(DEST$,"VERSVB.HLP"), "", cmoOverwrite
  318.     CreateProgmanItem "Versions/VB 1.1c", "Versions/VB 1.1c Visual Diff", MakePath(DEST$,"VISDIFF.EXE"), "", cmoOverwrite
  319.     CreateProgmanItem "Versions/VB 1.1c", "Versions/VB 1.1c Visual Diff Help", "WINHELP.EXE "+MakePath(DEST$,"VISDIFF.HLP"), "", cmoOverwrite
  320.     CreateProgmanItem "Versions/VB 1.1c", "Versions/VB 1.1c Release Notes", "WRITE.EXE "+MakePath(DEST$,"README.WRI"), "", cmoOverwrite
  321.     CreateProgmanItem "Versions/VB 1.1c", "Versions/VB 1.1c Documentation Errata", "WRITE.EXE "+MakePath(DEST$,"ERRATA.WRI"), "", cmoOverwrite
  322.     CloseLogFile
  323. END SUB
  324.  
  325.  
  326.  
  327. '*************************************************************************
  328. '**
  329. '** Purpose:
  330. '**     Appends a file name to the end of a directory path,
  331. '**     inserting a backslash character as needed.
  332. '** Arguments:
  333. '**     sDir$  - full directory path (with optional ending "\")
  334. '**     sFile$ - filename to append to directory
  335. '** Returns:
  336. '**     Resulting fully qualified path name.
  337. '**
  338. '*************************************************************************
  339. FUNCTION MakePath (sDir$, sFile$) STATIC AS STRING
  340.     IF sDir$ = "" THEN
  341.         MakePath = sFile$
  342.     ELSEIF sFile$ = "" THEN
  343.         MakePath = sDir$
  344.     ELSEIF MID$(sDir$, LEN(sDir$), 1) = "\" THEN
  345.         MakePath = sDir$ + sFile$
  346.     ELSE
  347.         MakePath = sDir$ + "\" + sFile$
  348.     END IF
  349. END FUNCTION
  350.  
  351.  
  352.  
  353.  
  354. '*************************************************************************
  355. '**
  356. '** Purpose:
  357. '**     Remove all previous installations if found.
  358. '** Arguments:
  359. '**     sDir$  - full directory path
  360. '**
  361. '*************************************************************************
  362. SUB UninstallPrevious (sDir$) STATIC
  363.     '' Remove previous 1.1 installation
  364.     RemovePrevInstalledFile sDir$, "CVCMPREL.PIF"
  365.     RemovePrevInstalledFile sDir$, "MSDNTB.DLL"
  366.     RemovePrevInstalledFile sDir$, "README.TXT"
  367.     RemovePrevInstalledFile sDir$, "VERS11.DLL"
  368. END SUB
  369.  
  370.  
  371.  
  372.  
  373. '*************************************************************************
  374. '**
  375. '** Purpose:
  376. '**     Deletes the file sFile$ from the directory sDir$,
  377. '**     if it exists.
  378. '** Arguments:
  379. '**     sDir$  - full directory path (with optional ending "\")
  380. '**     sFile$ - filename to be deleted
  381. '**
  382. '*************************************************************************
  383. SUB RemovePrevInstalledFile (sDir$, sFile$) STATIC
  384.     dim sFullPath as string
  385.  
  386.     sFullPath = MakePath(sDir$, sFile$)
  387.     if DoesFileExist(sFullPath, femExists) then
  388.         RemoveFile sFullPath, cmoForce
  389.     endif
  390. END SUB
  391.  
  392.